package charpter14.lynx;

import java.lang.reflect.Field;

public class Twentyfive {
	private static class Test{
		private int a = 0;
		protected int b = 1;
		public int c = 2;
		private final int d = 3;
		protected final int e = 4;
		public final int f = 5;
		
		public void print(){
			System.out.println(a);
			System.out.println(b);
			System.out.println(c);
			System.out.println(d);
			System.out.println(e);
			System.out.println(f);
		}
	}
	
	public static void main(String[] args) {
		Test test = new Test();
		try {//类的调用也差不多，用method获取就行了
			Field field = Test.class.getDeclaredField("a");
			field.setAccessible(true);
			field.set(test, 9);
			
			field = Test.class.getDeclaredField("b");
			field.setAccessible(true);
			field.set(test, 9);
			
			field = Test.class.getDeclaredField("c");
			field.setAccessible(true);
			field.set(test, 9);

			field = Test.class.getDeclaredField("d");
			field.setAccessible(true);
			field.set(test, 9);
			
			field = Test.class.getDeclaredField("e");
			field.setAccessible(true);
			field.set(test, 9);
			
			field = Test.class.getDeclaredField("f");
			field.setAccessible(true);
			field.set(test, 9);
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		
		test.print();
	}
}
